home *** CD-ROM | disk | FTP | other *** search
/ Sound Fx / Sound Fx.iso / Software / UNZIPED / MPW181-5 / _SETUP.1 / str_lib.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-15  |  2.1 KB  |  113 lines

  1. /* str_lib.cpp
  2.  
  3.    String manipulation routines for Win32 interface. Not needed
  4.    for other operating systems. Bad programming by Jeff Tsay.
  5.  
  6.    Last modified : 04/15/97 */
  7.  
  8. #ifdef  __WIN32__
  9. #define STRICT
  10. #define WIN32_LEAN_AND_MEAN
  11. #define NOMCX
  12. #define NOIME
  13. #define NOGDI
  14. #define NOUSER
  15. #define NOSOUND
  16. #define NOCOMM
  17. #define NODRIVERS
  18. #define OEMRESOURCE
  19. #define NONLS
  20. #define NOSERVICE
  21. #define NOKANJI
  22. #define NOMINMAX
  23. #define NOLOGERROR
  24. #define NOPROFILER
  25. #define NOMEMMGR
  26. #define NOLFILEIO
  27. #define NOOPENFILE
  28. #define NORESOURCE
  29. #define NOATOM
  30. #define NOLANGUAGE
  31. // #define NOLSTRING
  32. #define NODBCS
  33. #define NOKEYBOARDINFO
  34. #define NOGDICAPMASKS
  35. #define NOCOLOR
  36. #define NOGDIOBJ
  37. #define NODRAWTEXT
  38. #define NOTEXTMETRIC
  39. #define NOSCALABLEFONT
  40. #define NOBITMAP
  41. #define NORASTEROPS
  42. #define NOMETAFILE
  43. #define NOSYSMETRICS
  44. #define NOSYSTEMPARAMSINFO
  45. #define NOMSG
  46. #define NOWINSTYLES
  47. #define NOWINOFFSETS
  48. #define NOSHOWWINDOW
  49. #define NODEFERWINDOWPOS
  50. #define NOVIRTUALKEYCODES
  51. #define NOKEYSTATES
  52. #define NOWH
  53. #define NOMENUS
  54. #define NOSCROLL
  55. #define NOCLIPBOARD
  56. #define NOICONS
  57. #define NOMB
  58. #define NOSYSCOMMANDS
  59. #define NOMDI
  60. #define NOCTLMGR
  61. #define NOWINMESSAGES
  62. #define NOHELP
  63. #define _WINUSER_
  64.  
  65. #include <windows.h>
  66. #include "str_lib.h"
  67.  
  68. str_type my_itoa(int value, str_type str, int radix)
  69. // Negative numbers not supported, or radices bigger than 10
  70. {
  71.    char temp[256];
  72.  
  73.    if (value == 0) {
  74.        str[1] = '\0';
  75.       str[0] = '0';
  76.  
  77.     } else {
  78.  
  79.        temp[255]='\0';
  80.       int last_index;
  81.  
  82.        for(int i=254; i>=0, value>0; i--) {
  83.           int remainder = value % radix;
  84.           value /= radix;
  85.           temp[i] = (char) (remainder + '0');
  86.           last_index = i;
  87.        }
  88.  
  89.        lstrcpy(str, temp + last_index);
  90.    }
  91.  
  92.    return(str);
  93. }
  94.  
  95. int my_atoi(str_type str)
  96. // Negative numbers not supported
  97. {
  98.     int length = lstrlen(str);
  99.    int base = 1;
  100.    int result = 0;
  101.  
  102.    for(int i=length-1; i>=0; i--)
  103.    {
  104.         result += (str[i] - '0') * base;
  105.       base = (base << 3) + (base << 1);  // base*=10;
  106.    }
  107.  
  108.    return (result);
  109. }
  110.  
  111. #endif // __WIN32__
  112.  
  113.